<include file="Public:header" />
<script type="text/javascript">
$(function(){
    var body=$('body');
    var list=$('[name=list]');
    function actionRender(r,tr,k)
    {
        var edit=$('<span></span>').append('<img src="'+base_url+'/images/edit.png" border="0" style="cursor:pointer;" title="修改" alt="修改" />');
        var ok=$('<span></span>').append('<img src="'+base_url+'/images/add.png" border="0" style="cursor:pointer;" title="保存" alt="保存" />');
        var cancel=$('<span></span>').append('<img src="'+base_url+'/images/cancel.png" border="0" style="cursor:pointer;margin-left:10px;" title="取消" alt="取消" />');
        var bknum = tr.find('[name=bknum]');
        var stu_join  = tr.find('[name=stu_join]');
        var ac = tr.find('[name=action]');
        edit.click(function(){
            bknum.empty();
            bknum.append('<input type="text" size="2" name="bk_num_'+r.bk_id+'" maxlength="5" class="input_border" value="'+r.bk_num+'" />');
            ac.empty();
            var t = actionRender(r,tr,1);
            ac.append(t);
        });
        ok.click(function(){
            var kk=bknum.find('[name=bk_num_'+r.bk_id+']').val();
            alert(kk);
        });
        cancel.click(function(){
            bknum.empty();
            bknum.append(r.bk_num);
            ac.empty();
            var t = actionRender(r,tr,0);
            ac.append(t);
        });
        switch(k){
            case 0:
                return edit;
                break;
            case 1:
                return $('<span></span>').append(ok).append(cancel);
                break;
        }
    }
          
    //页面加载完毕后请求列表数据
    function getList(){
        $.getJSON(app_url+"/lfy-config-get_pc_list","",function(data){
            body.find('[name=tishi]').remove();
            var ro = eval(data);
            $.each(ro,function(n,c){
                var tr = $('<tr></tr>');
                var stujoin_td=$('<td align="center" name="stu_join"></td>').append(c.stu_join);
                var bknum_td=$('<td align="center" name="bknum"></td>').append(c.bk_num);
                var ac=$('<td align="center" name="action"></td>');
                tr.append(stujoin_td).append(bknum_td).append(ac);
                var acs=actionRender(c,tr,0);
                ac.append(acs);
                tr.appendTo(list);
            });
        });
    }
    //全部加载完之后执行
    getList();
 						
    });
</script>
<div style="margin-top: 30px;margin-left: 20px;">
    <b>各入学年级报考次数设置：</b><br /><br />
    【<a href="{:U('config/add_bknum')}">增加</a>】<br />
    <span id="pop" style="color:red;"></span><br />
    <table width="400px" border="1" name="list" cellpadding="0" cellspacing="0" style="border-collapse:collapse" bordercolor="#91A2AE">
        <tr height="25">
            <td width="30%" align="center">入学年级</td>
            <td width="30%" align="center">限制次数</td>
            <td width="40%" align="center">操作</td>
        </tr>
<!--        <foreach name="bk_list" item="bk">
            <tr>
            <td width="30%" align="center">{$bk.stu_join}</td>
            <td width="30%" align="center">{$bk.bk_num}</td>
            <td width="40%" align="center"><a href="<?php echo U('config/edit_bknum?id='.$bk['bk_id']);?>"><img src="__ROOT__/images/edit.png" border="0" /></a></td>
            </tr>
        </foreach>-->
            <tr height="25" name="tishi">
                <td width="100%" colspan="3" style="color:#91A2AE;text-align: center;"><img src="__ROOT__/images/loading.gif" />数据加载中...请稍后...</td>
            </tr>
    </table>
</div>
<include file="Public:ender" />
